"""
任务分配代理模块
本模块包含任务分配代理，负责将定义好的任务分配给合适的团队成员
该代理基于团队成员的专业技能进行智能任务分配
"""

from google.adk.agents import LlmAgent
import os
from google.adk.models.lite_llm import LiteLlm

# API密钥配置
DEFAULT_DASHSCOPE_API_KEY = "sk-f227634bb56*************************232"  # 请替换为您的实际密钥
DASHSCOPE_API_KEY = os.environ.get("DASHSCOPE_API_KEY", DEFAULT_DASHSCOPE_API_KEY)

# 任务分配代理 - 专门负责任务分配
# 该代理维护预定义的团队结构，并根据成员专长分配任务
# 团队成员包括：Alice(后端负责人)、Bob(前端开发)、Charlie(QA工程师)
task_assignment_agent = LlmAgent(
    name="TaskAssignmentAgent",  # 代理名称：任务分配代理
    model=LiteLlm(
                model="openai/qwen-turbo",  # 使用通义千问Turbo模型
                api_key=DASHSCOPE_API_KEY,
                api_base="https://dashscope.aliyuncs.com/compatible-mode/v1"
    ),
    instruction="""
    You are a task assignment specialist. You work with a predefined team: 
    - Alice (Backend Lead)
    - Bob (Frontend Developer) 
    - Charlie (QA Engineer)
    
    When given a list of tasks, assign each task to the most appropriate team member based on their expertise.
    
    Always return the assignments as a clear JSON object where keys are tasks and values are assigned team members.
    
    For example:
    Input: ["Design database schema", "Implement user interface", "Write test cases"]
    Output: {"Design database schema": "Alice", "Implement user interface": "Bob", "Write test cases": "Charlie"}

    Consider each team member's specialty:
    - Alice: Database design, backend architecture, API development
    - Bob: User interface, frontend frameworks, user experience
    - Charlie: Testing strategies, quality assurance, bug tracking
    
    Provide only the JSON object with assignments as your response.
    """,
    description="Assigns defined tasks to simulated team members based on their expertise."  # 代理描述：基于专业技能将任务分配给团队成员
)
